﻿using Core.DataAccess.Model.Project.Order;
using Core.Framework.Model.Common;
using System;
using System.Collections.Generic;
using System.Text;

namespace Core.Web.Controllers
{
    /// <summary>
    /// 订单请求参数
    /// </summary>
    public class OrderRequest
    {
        /// <summary>
        /// 订单主信息
        /// </summary>
        public OrderBasis orderBasis { get; set; }

        /// <summary>
        /// 订单地址
        /// </summary>
        public OrderAddress address { get; set; }

        /// <summary>
        /// 购物车
        /// </summary>
        public List<OrderUserCart> userCarts { get; set; }

        /// <summary>
        /// 商品
        /// </summary>
        public List<OrderProduct> products { get; set; }

        public void Page(ApiClientInfo apiClientInfo, ApiProjectInfo iProjectInfo)
        {

            if (this.userCarts?.Count > 0)
            {
                foreach (var item in this.userCarts)
                {
                    item.ProjectToken = iProjectInfo.Token;
                    item.UserKey = apiClientInfo.Key;
                }
            }

            this.orderBasis.RegTime = DateTime.Now;

            this.orderBasis.UserKey = apiClientInfo.Key;
            this.orderBasis.ProjectToken = iProjectInfo.Token;
        }
    }
}
